package com.zdp.strategy.handler;

import com.zdp.common.enums.ChannelType;
import com.zdp.strategy.entity.ChannelReq;

public abstract class AbstractChannelStrategy<P extends ChannelReq, R> {

    public abstract boolean apply(ChannelType channelType);

    protected abstract R mock();

    public final R invoke(P p) {
        // 设置渠道配置
        setChannelConfig(p.getConfigJson());
        // 执行调用渠道接口
        return this.doInvoke(p);
    }

    protected abstract void setChannelConfig(String channelConfig);

    protected abstract R doInvoke(P p);

}
